package com.slipper.system.collect.controller;

import com.slipper.system.collect.bo.CollectTableLogBO;
import com.slipper.system.collect.service.CollectTableLogService;
import com.slipper.util.Tool;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.slipper.system.collect.bo.CollectTaskLogBO;
import com.slipper.system.collect.service.CollectTaskLogService;
import com.slipper.util.ResultUtil;

/**
 * 采集任务日志
 */
@RestController
@RequestMapping("/system/collectTaskLog")
public class CollectTaskLogController {
    @Resource
    private CollectTaskLogService collectTaskLogService;
    @Resource
    private CollectTableLogService collectTableLogService;
    
    @PostMapping(value = "/queryBy")
    public String queryBy(@RequestBody CollectTaskLogBO bo) {
        if(Tool.isBlank(bo.getId())) {
            return ResultUtil.failureResult("数据获取失败！");
        }

        CollectTaskLogBO collectTaskLog = collectTaskLogService.queryBy(bo.getId());

        CollectTableLogBO qo = new CollectTableLogBO();
        qo.setTaskLogId(bo.getId());
        collectTaskLog.setTableLogList(collectTableLogService.queryList(qo));

        return ResultUtil.successResult(collectTaskLog);
    }

    @PostMapping(value = "/queryList")
    public String queryList(@RequestBody CollectTaskLogBO bo) {
        return ResultUtil.successResult(collectTaskLogService.queryList(bo));
    }
    
    @PostMapping(value = "/queryPage")
    public String queryPage(@RequestBody CollectTaskLogBO bo) {
        return ResultUtil.successResult(collectTaskLogService.queryPage(bo));
    }

    @PostMapping(value = "/save")
    public String save(@RequestBody CollectTaskLogBO bo) {
        return ResultUtil.saveResult(collectTaskLogService.save(bo), bo);
    }

    @PostMapping(value = "/delete")
    public String delete(@RequestBody CollectTaskLogBO bo) {
        return ResultUtil.deleteResult(collectTaskLogService.delete(bo));
    }
}
